#include "PhoneToSetZB3cmd.h"

SetUPZigbee3Cmd::SetUPZigbee3Cmd(QObject *parent)
    : BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package SetUPZigbee3Cmd::toPackage()
{
    Package package;
    return package;
}

void SetUPZigbee3Cmd::unPackage(Package package)
{
    Q_UNUSED(package);
}




AllowToJoinZigbee3Cmd::AllowToJoinZigbee3Cmd(QObject *parent)
    : BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package AllowToJoinZigbee3Cmd::toPackage()
{
    Package package;
    return package;
}

void AllowToJoinZigbee3Cmd::unPackage(Package package)
{
    Q_UNUSED(package);
}




ApplyToQuitZigbee3Cmd::ApplyToQuitZigbee3Cmd(QObject *parent)
    : BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package ApplyToQuitZigbee3Cmd::toPackage()
{
    Package package;
    package.setBody(m_nwk);
    return package;
}

void ApplyToQuitZigbee3Cmd::unPackage(Package package)
{
    m_nwk=package.body();
    m_cmdID=package.id();
}

quint16 ApplyToQuitZigbee3Cmd::cmdID()
{
    return m_cmdID;
}


ZBQuitFeedBackCmd::ZBQuitFeedBackCmd(QObject *parent)
    : BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package ZBQuitFeedBackCmd::toPackage()
{
    Package package;
    return package;
}

void ZBQuitFeedBackCmd::unPackage(Package package)
{
    m_cmdID=package.id();
}

quint16 ZBQuitFeedBackCmd::cmdID()
{
    return m_cmdID;
}

QueryZigbee3PropertiesCmd::QueryZigbee3PropertiesCmd(QObject *parent)
    : BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package QueryZigbee3PropertiesCmd::toPackage()
{
    Package package;
    return package;
}

void QueryZigbee3PropertiesCmd::unPackage(Package package)
{
   m_cmdID=package.id();
}
quint16 QueryZigbee3PropertiesCmd::cmdID()
{
    return m_cmdID;
}



SetZigbee3DataCmd::SetZigbee3DataCmd(QObject *parent)
    : BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package SetZigbee3DataCmd::toPackage()
{
    Package package;
    return package;
}
void SetZigbee3DataCmd::unPackage(Package package)
{

   QList<ControlPointStruct>addrList;
   ControlPointStruct pointStruct;
   pointStruct.setAddress(package.body().mid(3,2).toHex().toLong(0,16));
   qDebug()<<"pointaddr="<<pointStruct.address();
   addrList.append(pointStruct);

   quint8 namelength=package.body().mid(5,2).toHex().toInt(0,16);
   QString Name = QString::fromUtf8(package.body().mid(7,namelength));
   m_zigbee3Struct.setNwk(package.body().mid(0,2).toHex().toUpper());
  m_zigbee3Struct.setType(package.body().mid(2,1).toHex().toInt(0,16));
  m_zigbee3Struct.setPointList(addrList);
  m_zigbee3Struct.setName(Name);

  m_getCmdID=package.id();
   qDebug()<<"setNWK="<<DataTypeConver::formatString(package.body());
    qDebug()<<"setNWK1="<<m_zigbee3Struct.nwk();
    qDebug()<<"setType="<<m_zigbee3Struct.type();
}
Zigbee3Struct SetZigbee3DataCmd::zigbee3Struct()
{
    return m_zigbee3Struct;
}

quint16 SetZigbee3DataCmd::getcmdid()
{
    return m_getCmdID;
}

Zigbee3QueryDataCmd::Zigbee3QueryDataCmd(QObject *parent)
    : BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package Zigbee3QueryDataCmd::toPackage()
{
    Package package;
    return package;
}

void Zigbee3QueryDataCmd::unPackage(Package package)
{
   m_getcmdID=package.id();
}

quint16 Zigbee3QueryDataCmd::getcmdid()
{
  return m_getcmdID;
}
